package org.bob.common.constant;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 建议类型枚举
 */
public enum SuggestTypeEnum {

    /**
     * 中文
     */
    CHINESE(1,"chinese"),

    /**
     * 全拼
     */
    FULL_PINYIN(2,"full_pinyin"),

    /**
     * 首字母
     */
    HEAD_PINYIN(4,"head_pinyin");

    private int code;

    private String name;

    SuggestTypeEnum(int code,String name) {
        this.code = code;
        this.name = name;
    }

    public static List<SuggestTypeEnum> valuesOfCode(int code){
        return Arrays.stream(SuggestTypeEnum.values()).filter(suggestTypeEnum -> (suggestTypeEnum.code&code) !=0).collect(Collectors.toList());
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
